package com.heaven.exception;

import com.heaven.utils.R;
import lombok.Getter;

import java.io.Serial;

@Getter
public class RRException extends RuntimeException {
	@Serial
	private static final long serialVersionUID = 1L;
	
    private String msg;
    private int code = 500;

	public RRException(Throwable e){
		super(e);
		e.printStackTrace();
	}
    
    public RRException(String msg) {
		super(msg);
		this.msg = msg;
	}

	public RRException(R r) {
		super(r.getMsg());
		this.msg = r.getMsg();
		this.code = r.getCode();
	}
	
	public RRException(String msg, Throwable e) {
		super(msg, e);
		this.msg = msg;
		e.printStackTrace();
	}
	
	public RRException(String msg, int code) {
		super(msg);
		this.msg = msg;
		this.code = code;
	}
	
	public RRException(String msg, int code, Throwable e) {
		super(msg, e);
		this.msg = msg;
		this.code = code;
	}

	public RRException(BizCodeEnum bizCodeEnum, String errMsg,Throwable e) {
		super(bizCodeEnum.getMsg()+errMsg, e);
		this.msg = bizCodeEnum.getMsg()+errMsg;
		this.code = bizCodeEnum.getCode();
		e.printStackTrace();
	}

	public RRException(BizCodeEnum bizCodeEnum, Throwable e) {
		super(bizCodeEnum.getMsg(), e);
		this.msg = bizCodeEnum.getMsg()+e.getMessage();
		this.code = bizCodeEnum.getCode();
		e.printStackTrace();
	}

	public RRException(BizCodeEnum bizCodeEnum){
		super(bizCodeEnum.getMsg());
		this.msg = bizCodeEnum.getMsg();
		this.code = bizCodeEnum.getCode();
	}

	public RRException(BizCodeEnum bizCodeEnum, String message) {
		super(bizCodeEnum.getMsg()+message);
		this.msg = bizCodeEnum.getMsg()+message;
		this.code = bizCodeEnum.getCode();
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public void setCode(int code) {
		this.code = code;
	}
	
	
}
